package org.dromara.admin.domain.vo;

import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.dromara.admin.domain.ContractBill;
import org.dromara.admin.domain.GeneralConfig;
import org.dromara.admin.domain.Order;
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
import cn.idev.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import lombok.Data;
import org.dromara.lessor.domain.House;
import org.dromara.lessor.domain.vo.HouseVo;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysUserVo;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.List;


/**
 * 订单视图对象 hr_order
 *
 * @author Lion Li
 * @date 2025-09-03
 */
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = Order.class)
public class OrderVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @ExcelProperty(value = "主键ID")
    private Long id;

    /**
     * 订单编号（唯一业务编号）
     */
    @ExcelProperty(value = "订单编号", converter = ExcelDictConvert.class)
    private String contractNo;

    /**
     * 开始日期
     */
    @ExcelProperty(value = "开始日期")
    private Date startDate;

    /**
     * 结束日期
     */
    @ExcelProperty(value = "结束日期")
    private Date endDate;

    /**
     * 订单时长（3/6/12/24/36个月）
     */
    @ExcelProperty(value = "订单时长", converter = ExcelDictConvert.class)
    private Long contractMonth;

    /**
     * 租金（元）
     */
    @ExcelProperty(value = "租金", converter = ExcelDictConvert.class)
    private BigDecimal rent;

    /**
     * 押金/保证金（元）
     */
    @ExcelProperty(value = "押金/保证金", converter = ExcelDictConvert.class)
    private BigDecimal deposit;

    /**
     * 总金额（元）
     */
    @ExcelProperty(value = "总金额", converter = ExcelDictConvert.class)
    private BigDecimal rentTotal;

    /**
     * 房源id
     */
    @ExcelProperty(value = "房源id")
    private Long houseId;

    /**
     * 租客id
     */
    @ExcelProperty(value = "租客id")
    private Long userId;

    /**
     * 出租方id
     */
    @ExcelProperty(value = "出租方id")
    private Long lessorUserId;

    /**
     * 资方代理id
     */
    @ExcelProperty(value = "资方代理id")
    private Long capitalUserId;

    /**
     * 用户授权图片url
     */
    @ExcelProperty(value = "用户授权图片url")
    private String userAuthUrl;

    /**
     * 合同唯一编码
     */
    @ExcelProperty(value = "合同唯一编码")
    private String contractCode;

    /**
     * 资方备注
     */
    @ExcelProperty(value = "资方备注")
    private String capitalRemarks;

    /**
     * 备注记录ids
     */
    @ExcelProperty(value = "备注记录ids")
    private String remarks;

    /**
     * 订单状态: PENDING(待生效)，SIGNING(签约中), EFFECTING(生效中), CANCELLING(取消),TERMINATING(解约中), ENDED(已结束)
     */
    @ExcelProperty(value = "订单状态: PENDING(待生效), EFFECTING(生效中), CANCELLING(取消中), TERMINATION_PENDING(待解约), TERMINATING(解约中), ENDED(已结束)")
    private String orderStatus;

    /**
     * 签约状态: SIGNING(签约中), AUDIT(审核中), SUCCESS(完成), DEFAULT(违约)
     */
    @ExcelProperty(value = "签约状态: SIGNING(签约中), AUDIT(审核中), SUCCESS(完成), DEFAULT(违约)")
    private String signingStatus;

    /**
     * 平台审核状态: PENDING(待审核), APPROVED(已审核), REJECTED(拒绝), REJECTED_AND_REASSIGN(驳回（资方审核拒绝后，可以驳回重新分配资方）)
     */
    @ExcelProperty(value = "平台审核状态: PENDING(待审核), APPROVED(已审核), REJECTED(拒绝), REJECTED_AND_REASSIGN(驳回", converter = ExcelDictConvert.class)
    private String platformAuditStatus;

    /**
     * 资方审核状态: PENDING(待审核), APPROVED(通过), REJECTED(拒绝)
     */
    @ExcelProperty(value = "资方审核状态: PENDING(待审核), APPROVED(通过), REJECTED(拒绝)")
    private String capitalAuditStatus;

    /**
     * 押金状态: PENDING_PAY(待支付), PAID(已支付), FREE(已免押), REFUNDED(已退款)
     */
    @ExcelProperty(value = "押金状态: PENDING_PAY(待支付), PAID(已支付), FREE(已免押), REFUNDED(已退款)")
    private String pledgeStatus;

    /**
     * 租金分期账单状态: PENDING_PAY(待支付), PAID(已支付), OVERDUE(已逾期)
     */
    @ExcelProperty(value = "租金分期账单状态: PENDING_PAY(待支付), PAID(已支付), OVERDUE(已逾期)")
    private String rentBillStatus;

    /**
     * 垫资分期账单状态: PENDING_PAY(待支付), PAID(已打款), OVERDUE(已逾期)
     */
    @ExcelProperty(value = "垫资分期账单状态: PENDING_PAY(待支付), PAID(已打款), OVERDUE(已逾期)")
    private String advanceBillStatus;

    /**
     * 签约时间
     */
    @ExcelProperty(value = "签约时间")
    private Date signingTime;

    /**
     * 审核时间
     */
    @ExcelProperty(value = "审核时间")
    private Date auditTime;

    /**
     * 创建时间
     */
    @ExcelProperty(value = "创建时间")
    private Date createTime;

    /**
     * 房源信息
     */
    @ExcelProperty(value = "房源信息")
    private HouseVo house;

    private GeneralConfigVo generalConfig;

    /**
     * order关联的账单信息
     */
    @ExcelProperty(value = "order关联的账单信息")
    private List<ContractBillVo> contractBills;

    /**
     * 租客信息
     */
    private SysUserVo tenantUser;
    /**
     * 出租方信息
     */
    private SysUserVo lessorUser;
    /**
     * 资方代理信息
     */
    private SysUserVo capitalUser;

    /**
     * 资方垫资金额
     */
    @ExcelProperty(value = "资方垫资金额")
    private BigDecimal capitalAdvanceAmount;

}
